<template >
    <div class="school">
        <h1 >学校姓名:{{name }}</h1>
        <h1 >地址:{{address}}</h1>
    </div>
</template>



<script>


import pubsub from 'pubsub-js'
export default {
    name:'School',
    data() {
        return {
            name:'清华',
            address: '北京'
        }
    },mounted(){
        // this.$bus.$on("hello",(data)=>{
        //     console.log(this.$bus)
        //     console.log("我是School组件,收到数据",data)
        // })
        this.pubId=pubsub.subscribe("hello",(msgName,data)=>{
         console.log("我是School组件,有人发布了hello数据，我订阅到数据了",msgName,data,this)
        })
    },destroyed(){
        // this.$bus.$off('hello')
        pubsub.unnsubscribe(this.pubId);
    }
   }
</script>

<style scoped>
.school{
    background-color: rgb(255, 0, 89);
    padding: 5px;
}
</style>